home *** CD-ROM | disk | FTP | other *** search
- Path: ix.netcom.com!news
- From: ee384@ix.netcom.com(Danny Pham)
- Newsgroups: comp.lang.c++
- Subject: Need help w/ while loop in "CLASS"!!!
- Date: 12 Mar 1996 12:55:02 GMT
- Organization: Netcom
- Message-ID: <4i3s76$rvg@dfw-ixnews2.ix.netcom.com>
- NNTP-Posting-Host: irv-ca13-18.ix.netcom.com
- X-NETCOM-Date: Tue Mar 12 6:55:02 AM CST 1996
-
- Hi,
- I am really need help on this program. I try to write a program
- that involved a link list. But I have a problem with my while loop. The
- following is my code:
-
- Class Stack
- {
- struct linklist
- {
- int Numberlist;
- struct linklist *nextlist;
- };
- private:
- |
- |
- |
- public:
- Stack();
- ~stack();
- Bool Push(const int &Numberlist);
- Bool Pop(int &Number);
- |
- |
- };
-
- /////////////////////////
- main()
- {
- int number, Local, select;
-
- stack mylist;
- mylist.mainmenu(); // menu for user to select push,pop ...
- cin >> select;
- while(select !=5)
- {
- switch(select)
- {
- case 1:
- while(number = getnumber(&local))
- {
- mylist.push(number);
- }
- break;
- case 2:
- |
- |
- }
- mylist.mainmenu()
- cin >> select;
- }
- return 0;
- }
-
- //////////////////
- int getnumber (int *number)
- {
- cout << "please enter a number(Q or q to stop):";
- cin >> *number;
- return *number;
- }
-
- /////////////////////////
- I used a debug program and I found out that when I entered 'q', it
- jumped to "mylist.mainmenu() again" and it ran non-stop. Please give me
- a hint on this problem.
- Thank you very much !!!!
- D.P
-
-
-